<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Description of Pages
 *
 * @author jay
 */
class Login extends CI_Controller{
 	
 	function index() { 
		$data['text_signin'] = $this->lang->line('text_signin');
		$data['text_rememberme'] = $this->lang->line('text_rememberme');
		$data['button_signin'] = $this->lang->line('button_signin');
		$data['text_email'] = $this->lang->line('text_email');
		$data['text_password'] = $this->lang->line('text_password');
		
 		$this->load->view('login_view', $data);
 	}	
	
	function logincheck() {
		$uname = $this->input->post('uname');
		$upwd = $this->input->post('upwd');
	
		// Load the model
		$this->load->model('login_model');
				
		// Validate user for login
		$result = $this->login_model->validate();
		
		if(!$result) {
			$this->index();
		} else {
			redirect('Home');
		}
	}
	
	function logout() {
		$this->session->sess_destroy();
		redirect('Login');
	}
	
}
?>
